package com.c.ctgproject.ui.sell.material

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.MyLog
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken
import okhttp3.MultipartBody

class SaleApplyViedModel : BaseViewModel() {
    private val mApplyResult = MutableLiveData<String>()
    val applyResult: LiveData<String> get() = mApplyResult

    fun saleApply(body: ArrayList<MultipartBody.Part>) {
        launch({
            mApplyResult.value = ApiMethods.getApiService().materialSaleApply(userToken, body).awaitSync()
            MyLog.d("回调${mApplyResult.value}")
        }, {
            mError.value = it.message.toString()
            MyLog.d("错误${mError.value}")
        })
    }
}